home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_AddDelete_JScript.asp < prev    next >
Encoding:
Text File  |  1999-07-21  |  1.5 KB  |  60 lines

  1. <%@ LANGUAGE = JScript %>
  2. <%  Response.Expires= -1 %>
  3. <!--METADATA TYPE="typelib" 
  4. uuid="00000205-0000-0010-8000-00AA006D2EA4" -->
  5.  
  6.  
  7. <HTML>
  8.     <HEAD>
  9.         <TITLE>Add/Delete Database Sample</TITLE>
  10.     </HEAD>
  11.  
  12.     <BODY BGCOLOR="White" topmargin="10" leftmargin="10">
  13.  
  14.         <!-- Display Header -->
  15.  
  16.         <font size="4" face="Arial, Helvetica">
  17.         <b>Add/Delete Database Sample</b></font><br>
  18.       
  19.         <hr size="1" color="#000000">
  20.  
  21.  
  22.         <%
  23.             var oConn;    
  24.             var oRs;        
  25.             var filePath;    
  26.  
  27.             
  28.             // Map authors database to physical path
  29.  
  30.             filePath = Server.MapPath("authors.mdb");
  31.  
  32.  
  33.             // Create ADO Connection Component to connect
  34.             // with sample database
  35.             
  36.  
  37.             
  38.             oConn = Server.CreateObject("ADODB.Connection");
  39.             oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +filePath);
  40.  
  41.             // to add and delete recordset, it is recommended to use 
  42.             //direct SQL statement instead of ADO methods.
  43.             
  44.             oConn.Execute ("insert into authors (author, YearBorn) values ('Paul Enfield', 1967)");
  45.  
  46.             // Output Result
  47.             oRs = oConn.Execute ( " Select * from authors where Author= 'Paul Enfield' and YearBorn =1967 " ); 
  48.             Response.Write("<p>Inserted Author: "+oRs("Author")+"," + oRs("YearBorn"));
  49.  
  50.             // Delete inserted record
  51.             
  52.             oConn.Execute ( " Delete from Authors where author='Paul Enfield' and YearBorn = 1967" );
  53.         
  54.             // Output Status Result
  55.             
  56.             Response.Write("<p>Deleted Author: Paul Enfield, 1967");
  57.         %>
  58.     </BODY>
  59. </HTML>
  60.